package APong.Entity;

import java.util.Random;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.geom.Rectangle;
import org.newdawn.slick.geom.Shape;
import org.newdawn.slick.state.StateBasedGame;

import APong.World.World;

public class ScoreZone extends Entity {
public static Random random = new Random();
	public ScoreZone(World world, float x, float y, int w, int h) {
		super(world, x, y, w, h);
		
	}

	@Override
	protected void renderEntity(GameContainer gc, Graphics g) {
		this.drawCollisionShape(g);
		
	}

	@Override
	protected void updateEntity(GameContainer gc, StateBasedGame sbg) {
		
		
	}

	@Override
	public Shape getCollisionShape(float xa, float ya) {
		return new Rectangle(x + xa, y + ya, width, height);
	}

	@Override
	public boolean isSolid(Entity e) {
		return true;
	}

	@Override
	public void collide(Entity e) {
		if(e instanceof Ball){
			e.setXPos(200);
			e.setYPos(200);
			e.setXVel(.4f);
			int i = random.nextInt(2);
			switch(i){
			case 0: e.setXVel(.4f); break;
			case 1: e.setYVel(-.4f); break;
			}
			if(this.x <= 0){
				world.Player1++;
			}
		}
		
	}

}
